package com.jason.reflect.myunit;

import java.lang.reflect.Method;
import java.util.Scanner;

/**
 * @Author: Jason
 * @Date: 16/8/1
 * @Time: 23:39
 */
public class MyUnit {

    public static void main(String[] args) throws Exception {
        //
        System.out.println("请你输入要被测试的类:");

        Scanner sc = new Scanner(System.in);
        String clsName = sc.nextLine();

        Class<?> cls = Class.forName(clsName);
        Object obj = cls.newInstance();

        // 获取里面的所有public方法
        Method[] ms = cls.getDeclaredMethods();
        for (Method mt : ms) {
            if (mt.isAnnotationPresent(MyTest.class)) {
                mt.invoke(obj);
            }
        }


    }
}
